<template>
  <div class="sysSetting-root">
    <van-sticky>
      <van-nav-bar title="设置" left-arrow @click-left="$router.goBack()" />
    </van-sticky>

    <div
      class="row flex-btw"
      v-for="item in navList"
      :key="item.name"
      @click="$goRouter(item.url)"
    >
      <div class="name">{{ item.name }}</div>

      <img src="@/assets/images/sysSetting/right.png" alt="" />
    </div>

    <div class="btn" @click="loginOut">退出登陆</div>
  </div>
</template>

<script>
import mixin from "@/mixin.js";
import { USER_LOGIN_OUT } from "@/api/api.js";
import { Toast } from "vant";
//import { setLocalStorage } from '@/util/local-storge.js';
export default {
  name: "sysSetting",
  mixins: [mixin],
  data() {
    return {
      navList: [
        {
          name: "个人资料",
          url: "personal",
        },
        {
          name: "手机号码/邮箱",
          url: "phone",
        },
        {
          name: "修改登录密码",
          url: "password",
        },
        {
          name: "修改支付密码",
          url: "payPSD",
        },
        {
          name: "联系我们",
          url: "",
        },
        {
          name: "清除缓存",
          url: "",
        },
      ],
    };
  },
  methods: {
    async loginOut() {
      const { data } = await this.$reqPost(USER_LOGIN_OUT);
      if (data.status == 0) {
        Toast.fail(data.info);
      }
      if (data.status == 1) {
        localStorage.removeItem("token");
        let that = this;
        Toast.success({
          message: "退出登录成功!",
          onClose: function() {
            that.$router.push({ name: "login" });
          },
        });
      }
      this.$router.push("login");
    },
  },
};
</script>

<style lang="scss" scoped>
.sysSetting-root {
  background-color: #f0eeee;
  min-height: 100%;

  .row {
    background-color: #fff;
    padding: 0.45rem 0.3rem;
    font-size: 0.26rem;
    border-bottom: 0.02rem solid #f0eeee;
    color: #141414;
    img {
      width: 0.12rem;
      height: 0.2rem;
    }
  }

  .btn {
    width: 5.6rem;
    height: 0.8rem;
    background-color: #2d7afe;
    font-size: 0.3rem;
    color: #fff;
    line-height: 0.8rem;
    border-radius: 0.1rem;
    margin: 3.12rem auto 0;
  }
}
</style>
